#delimit;
set logtype text;
log using mlogit_replication.out, replace; 
set more off;

/* input data from replication data set housed on JCR web-site */

use GelpiFeb2009;

tab iraqwin warsucc, column;
tab disapptimetable;

/* now merge data from http://people.duke.edu/~gelpi/data.htm before
any recoding has been done to show that the merge produces datasets
that are from the same study */

/* Note, this set no longer available at Duke, but the zip file
containing this file is listed (though not currently available) at
http://politicalscience.osu.edu/faculty/gelpi.10/datasets.htm as
GelpiPOCReplication.zip */

merge 1:1 caseid using GelpiPOC;

tab iraqwin warsucc, column;
tab approvetimetable;
tab approvetimetable disapptimetable, column;
tab apptimetable approvetimetable, column;
tab apptimetable disapptimetable, column;

/* having done that, let's start from the beginning with the first
task being using the data from the JCR web-site to replicate the
published results */

gen disapptimetable4=3-apptimetable;
tab disapptimetable4 apptimetable;
tab disapptimetable apptimetable;
tab disapptimetable disapptimetable4;

gen bushapp4=4-bushapprove;

/* reproduce Gelpi's (2017) Withdrawal results from his Table 3 */ 
/* results replicate exactly */

mlogit disapptimetable4 posevents negevents posbush negbush if 
bushapp4==0, base(1);

mlogit disapptimetable4 posevents negevents posbush negbush if 
bushapp4==1, base(1);

mlogit disapptimetable4 posevents negevents posbush negbush if 
bushapp4==2, base(1);

mlogit disapptimetable4 posevents negevents posbush negbush if 
bushapp4==3, base(1);

/* Reproduce Gelpi's (2017) Withdrawal results from his Figure 3 */ 
/* results replicate approximately.  */

estsimp mlogit disapptimetable4 posevents negevents posbush negbush if 
bushapp4==0, base(1);

setx 0;
simqi, fd(prval(0))  changex(posevents 0 1);
simqi, fd(prval(1))  changex(posevents 0 1);
simqi, fd(prval(2))  changex(posevents 0 1);
simqi, fd(prval(3))  changex(posevents 0 1);
drop b1-b15;

estsimp mlogit disapptimetable4 posevents negevents posbush negbush if
bushapp4==1, base(1);

setx 0;
simqi, fd(prval(0))  changex(posevents 0 1);
simqi, fd(prval(1))  changex(posevents 0 1);
simqi, fd(prval(2))  changex(posevents 0 1);
simqi, fd(prval(3))  changex(posevents 0 1);
drop b1-b15;

estsimp mlogit disapptimetable4 posevents negevents posbush negbush if
bushapp4==2, base(1);

setx 0;
simqi, fd(prval(0))  changex(negevents 0 1);
simqi, fd(prval(1))  changex(negevents 0 1);
simqi, fd(prval(2))  changex(negevents 0 1);
simqi, fd(prval(3))  changex(negevents 0 1);

drop b1-b15;

estsimp mlogit disapptimetable4 posevents negevents posbush negbush if
bushapp4==3, base(1);

setx 0;
simqi, fd(prval(0))  changex(posevents 0 1);
simqi, fd(prval(1))  changex(posevents 0 1);
simqi, fd(prval(2))  changex(posevents 0 1);
simqi, fd(prval(3))  changex(posevents 0 1);

simqi, fd(prval(0))  changex(negbush 0 1);
simqi, fd(prval(1))  changex(negbush 0 1);
simqi, fd(prval(2))  changex(negbush 0 1);
simqi, fd(prval(3))  changex(negbush 0 1);

/* Reproduce results from my Table 1 */

mlogit disapptimetable4 i.posevents i.negevents i.posbush i.negbush if
bushapp4==0, base(1);

margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe01=r(table)';
matrix pe0=pe01[1..4,1..2];
margins r.negbush, at(posevents=0 negevents=0 posbush=0);
matrix nb01=r(table)';
matrix nb0=nb01[1..4,1..2];
matrix ob01=r(_N);
matrix ob0=ob01[1,1..2];

mlogit disapptimetable4 i.posevents i.negevents i.posbush i.negbush if
bushapp4==1, base(1);

margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe11=r(table)';
matrix pe1=pe11[1..4,1..2];
margins r.negbush, at(posevents=0 negevents=0 posbush=0);
matrix nb11=r(table)';
matrix nb1=nb11[1..4,1..2];
matrix ob11=r(_N);
matrix ob1=ob11[1,1..2];

mlogit disapptimetable4 i.posevents i.negevents i.posbush i.negbush if
bushapp4==2, base(1);

margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe21=r(table)';
matrix pe2=pe21[1..4,1..2];
margins r.negbush, at(posevents=0 negevents=0 posbush=0);
matrix nb21=r(table)';
matrix nb2=nb21[1..4,1..2];
matrix ob21=r(_N);
matrix ob2=ob21[1,1..2];

mlogit disapptimetable4 i.posevents i.negevents i.posbush i.negbush if
bushapp4==3, base(1);

margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe31=r(table)';
matrix pe3=pe31[1..4,1..2];
margins r.negbush, at(posevents=0 negevents=0 posbush=0);
matrix nb31=r(table)';
matrix nb3=nb31[1..4,1..2];
matrix ob31=r(_N);
matrix ob3=ob31[1,1..2];
log close;

log using tables/table1.txt, replace;
matrix tab=(pe0,pe1,pe2,pe3 \ nb0,nb1,nb2,nb3 \ ob0,ob1,ob2,ob3);
matrix list tab;
log close;

matrix drop pe0 pe1 pe2 pe3 ob0 ob1 ob2 ob3 nb0 nb1 nb2 nb3;
matrix drop pe01 pe11 pe21 pe31 ob01 ob11 ob21 ob31 nb01 nb11 nb21
nb31; 

log using tables/tableA1.txt, replace;
/* Reproduce results from Table A.1 in the Supplemental Materials */

mlogit iraqwin posevents negevents posbush negbush if bushapp4==3,
base(0); 
mlogit iraqwin posevents negevents posbush negbush if bushapp4==3,
base(2);
log close;

log using mlogit_replication.out, append;
/* Reproduce results from Table A.2 in the Supplemental Materials */

mlogit iraqwin i.posevents i.negevents i.posbush i.negbush if
bushapp4==0, base(1);
margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe01=r(table)';
matrix pe0=pe01[1..4,1..2];
matrix ob01=r(_N);
matrix ob0=ob01[1,1..2];

mlogit iraqwin i.posevents i.negevents i.posbush i.negbush if
bushapp4==1, base(1);
margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe11=r(table)';
matrix pe1=pe11[1..4,1..2];
matrix ob11=r(_N);
matrix ob1=ob11[1,1..2];

mlogit iraqwin i.posevents i.negevents i.posbush i.negbush if
bushapp4==2, base(1);
margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe21=r(table)';
matrix pe2=pe21[1..4,1..2];
matrix ob21=r(_N);
matrix ob2=ob21[1,1..2];

mlogit iraqwin i.posevents i.negevents i.posbush i.negbush if
bushapp4==3, base(1);
margins r.posevents, at(negevents=0 posbush=0 negbush=0);
matrix pe31=r(table)';
matrix pe3=pe31[1..4,1..2];
matrix ob31=r(_N);
matrix ob3=ob31[1,1..2];
log close;

log using tables/tableA2.txt, replace;
matrix tab=(pe0,pe1,pe2,pe3 \ ob0,ob1,ob2,ob3);
matrix list tab;
log close;

log using mlogit_replication.out, append;

/* Reproduce results for Greenhill and Oppenheim (2017) */
/* Thailand coup rumors first */

clear;

use "2015-05-0216.R2 Rumor_Has_It--_Thailand_replication_data.dta";

/* copy multinomial logit code from archived do file */

/* Greenhill and Oppenheim Table 4 model (4): Full sample */
mlogit believe_coup distrust_military threat_perception
heard_coup_rumor male age muslim income education social_trust
local_participation, base(0) r rrr;

/* threat perception: significance levels of marginal effects smaller
than the levels for the MNL coefficients */
margins, dydx(threat_perception);

margins, at((mean) _all threat_perception=(1(1)4)) post;

/* Reproduce Figure 1a */

marginsplot, xdimension(threat_perception) title(Acceptance of Coup
Rumors) ytitle(Predicted Probability) plot1opts(lpattern(solid)
msymbol(O)) plot2opts(lpattern(dash) msymbol(T))
plot3opts(lpattern(dash) msymbol(Dh)) xlabel(1 "Very Unlikely" 4 "Very
Likely", labsize(vsmall)) plotd(,label( "Deny" "Plausible" "Accept"))
legend(row(1));

graph export figures/figure1a.eps, as(eps) replace;
/* Delete next line if not using linux */
!epstopdf /figures/figure1a.eps -o=/figures/figure1a.pdf;

quietly: mlogit believe_coup distrust_military threat_perception
heard_coup_rumor male age muslim income education social_trust
local_participation, base(0) r rrr;

margins, at((mean) _all threat_perception=(1(1)4)) post;

/* predicted probability difference between low and high threat
perception */
lincom _b[3._predict#1bn._at] - _b[3._predict#4._at];

/* Now Philippines corruption rumors */

clear;
use "2015-05-0216.R2 Rumor_Has_It--_Philippines_replication_data.dta";

/* Add in values for dependent variable */

label define believe_IRA_v 0 "Deny" 1 "Plausible" 2 "Accept";
label values believe_IRA believe_IRA_v;

/* Greenhill and Oppenheim Table 7 MNL model (3): Unexposed sample */

mlogit believe_IRA distrust_local_officials economic_fear male age
muslim income education social_trust  local_participation if
heard_IRA==0, base(0) r rrr;

margins, at((mean) _all distrust_local_officials=(1(1)5)) post;

/* Reproduce Figure 1b */
marginsplot, xdimension(distrust_local_officials) title(Acceptance of
Corruption Rumors) ytitle(Predicted Probability)
plot1opts(lpattern(solid) msymbol(O)) plot2opts(lpattern(dash)
msymbol(T)) plot3opts(lpattern(dash) msymbol(Dh)) xlabel(1 "Low" 5
"High") plotd(,label( "Deny" "Plausible" "Accept")) legend(row(1)); 

graph export figures/figure1b.eps, as(eps) replace;
/* Delete next two lines if not using linux */
!epstopdf figures/figure1b.eps -o=figures/figure1b.pdf;

/* Probability difference accepting corruption rumor between lowest
and highest levels of distrust */
lincom _b[3._predict#1bn._at] - _b[3._predict#5._at];

/* Reproduce Weber et al.'s (2014) results */
/* First part of code comes directly from Weber et al.'s replication file */

#delimit cr
clear

use "replication data.dta"

//Various Measures of Context//
************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************//Heterogeneity Measure that is in the Paper//gen p1=(hispanic)+(black)+(asian)+(white)gen sum1=(hispanic^2)+(black^2)+(asian^2)+(white^2)gen het=p1-sum1
set scheme s2monograph twoway histogram het || kdensity het, bwidth(0.05) ytitle("density") xtitle("Heterogeneity, All Groups") legend(label(1 "Histogram") label(2 "Kernel Density") )
//A zero to 1 scale//replace het=(het-0.0178418)/.6732611 
 ////////////////
//Black v. White Heterogeneity//
//This is the measure in the paper, the rest are for the appendix//gen p2=(black)+(white)gen sum2=(black^2)+(white^2)
gen het2=p2-sum2
graph twoway histogram het2 || kdensity het2, bwidth(0.05) ytitle("density") xtitle("Heterogeneity, Blacks/Whites") legend(label(1 "Histogram") label(2 "Kernel Density") )

//Just percentage black//
graph twoway histogram black || kdensity black, bwidth(0.05) ytitle("density") xtitle("Percent Black") legend(label(1 "Histogram") label(2 "Kernel Density") )

//Black:White//gen dif=(black)-(white)graph twoway histogram dif || kdensity dif, bwidth(0.05) ytitle("density") xtitle("Heterogeneity, Blacks-Whites") legend(label(1 "Histogram") label(2 "Smoothed Density") )
*replace this to vary from 0 to 1
sum dif
replace dif=(dif+ .9870968 )/1.712533
gen lndif=ln(dif+.01)  
  ///Generate Don't Now and Midpoint responses for dissembling analysis////gen mid1=1 if workbla==5replace mid1=2 if workbla>5 & workbla<11replace mid1=3 if workbla<5replace mid1=4 if workbla>10gen mid2=1 if violbla==5replace mid2=2 if violbla>5 & violbla<11replace mid2=3 if violbla<5replace mid2=4 if violbla>10**Labels high scores are reject for the working stereotype, but endorse blacks as violent for the violent stereotype** label define mid1 1 "midpoint" 2 "reject" 3 "endorse" 4 "opt out"label values mid1 mid1label define mid2 1 "midpoint" 2 "endorse" 3 "reject" 4 "opt out"label values mid2 mid2
**Recode so that dissembling is reject, midpoint, or opt out.
recode mid1 (1 2 4=1) (3=0), gen(dissemble1)
recode mid2 (1 3 4=1) (2=0), gen(dissemble2)

************************************************************************************************************************************************************************************

//Independent variables//
************************************************************************************************************************************************************************************
//egalitarianism scale//
recode eqright (5 6=.), gen(eqright_r)
recode eqchanc (1=4) (2=3) (3=2) (4=1)  (5 6=.), gen(eqchanc_r)
recode eqpeopl (5 6=.), gen(eqpeopl_r)
replace eqright_r=(eqright_r-1)/3
replace eqchanc_r=(eqchanc_r-1)/3
replace eqpeopl_r=(eqpeopl_r-1)/3
egen egalitarianism=rmean(eqright_r eqpeopl_r)label variable eqright_r "eqright reversed 0-1"label variable eqpeopl_r "eqpeopl reversed 0-1"label variable eqchanc_r "eqchanc 0-1"
//individualism scale//
recode blame (1=4) (2=3) (3=2) (4=1) (5 6=.), gen(blame_r)
recode hardwrk  (5 6=.), gen(hardwrk_r)
recode poverty (1=3) (2=1) (3=2) (4=2) (5 6=.), gen(poverty_r)
replace blame_r=(blame_r-1)/3
replace hardwrk_r=(hardwrk_r-1)/3
replace poverty_r=(poverty_r-1)/3
alpha blame_r poverty_r
egen individualism=rmean(blame_r poverty_r)label variable blame_r "blame reversed, 0-1"label variable hardwrk_r "hardwrk 0-1"label variable poverty_r "poverty reversed, 0-1"//PID and Ideology//
**High scores are republicans and conservatives**gen pid=.replace pid=1 if strongr==1replace pid=.83 if strongr==2 | strongr==3replace pid=.67 if closer==1replace pid=.5 if closer==3 | closer==4replace pid=.33 if closer==2replace pid=.17 if strongd==2 | strongd==3replace pid=0 if strongd==1gen libcon=.replace libcon=1 if conserv==1replace libcon=.83 if conserv==2 | conserv==3replace libcon=.67 if moderat==2replace libcon=.5 if moderat==3 | moderat==4 | moderat==5 | moderat==6replace libcon=.33 if moderat==1replace libcon=.17 if liberal==2 | liberal==3replace libcon=0 if liberal== 1//self monitoring scale//recode i_expec (1=4) (2=3) (3=2) (4=1) (5 6=.), gen(i_expec_r)
recode i_amnot (1=4) (2=3) (3=2) (4=1) (5 6=.), gen(i_amnot_r )
recode i_nojoy (1=4) (2=3) (3=2) (4=1) (5 6=.), gen(i_nojoy_r)
recode i_deciv (1=4) (2=3) (3=2) (4=1) (5 6=.), gen(i_deciv_r )
replace i_expec_r=(i_expec_r-1)/3
replace i_amnot_r=(i_amnot_r-1)/3
replace i_nojoy_r=(i_nojoy_r-1)/3
replace i_deciv_r=(i_deciv_r-1)/3
alpha i_expec_r i_amnot_r i_nojoy_r i_deciv_r
egen smonitor=rmean(i_expec_r i_amnot_r i_nojoy_r i_deciv_r)label variable i_expec_r "i_expec reverse 0-1"label variable i_amnot_r "i_amnot reverse 0-1"label variable i_nojoy_r "i_nojoy reverse 0-1"label variable i_deciv_r "i_deciv reverse 0-1"//stereotypes towards blacks//replace workbla=. if workbla>10replace violbla=. if violbla>10gen workbla0=((11-workbla)-1)/9gen violbla0=(violbla-1)/9//welfare and poverty stereotypes for  blacks
gen welfbla0=welfarb
replace welfbla0=. if welfbla0>10
replace welfbla0=(welfbla0-1)/9
replace wealthb=. if wealthb>10
gen poorbla0=((11-wealthb)-1)/9
//stereotypes towards whites
replace workwhi=. if workwhi>10replace violwhi=. if violwhi>10gen workwhi0=((11-workwhi)-1)/9gen violwhi0=(violwhi-1)/9


//Generate several "difference" measures//
gen d1_violent=violbla0-violwhi0
gen d1_work=workbla0-workwhi0
reg violbla0 violwhi0predict d2_violent, residuals
reg workbla0 workwhi0predict d2_work, residuals



//Age//
replace yearbrn=. if yearbrn>1983
gen age=2001-yearbrn
gen agemiss=age==.




//Other Demographic Variables
*Education is 1 if some college or greaterrecode educ 1 2 3 4 5 6 7 = 0 8=0 9 10=0 11=1 12 13 14=1 15 16=.*1 is femalerecode gender 2=0 3=.//racial resentmentgen irish_r=irishgen tryhard_r =tryhardgen deserve_r=deservegen slavery_r=slaveryrecode irish_r 1=1 2=.75 5 6=.5 3=.25 4=0recode tryhard_r 1=1 2=.75 5 6=.5 3=.25 4=0recode deserve_r 1=0 2=.25 5 6=.5 3=.75 4=1recode slavery_r 1=0 2=.25 5 6=.5 3=.75 4=1gen discrim_r=discrimgen noeduc_r=noeducreplace discrim_r=1-discrim_rreplace noeduc_r=1-noeduc_regen resent4= rmean (irish_r tryhard_r deserve_r slavery_r)label variable resent4 "K & S 4-item resetnment scale" ************************************************************************************************************************************************************************************

//Dependent variables//
************************************************************************************************************************************************************************************//Affirmative Actionrecode homeown 3 4=.recode integr 5 6=.recode locgov 5 6=.recode spended 5 6=.recode affact1 3 4=.recode affact2 3 4=.gen affact1_01=affact1recode affact1_01 1=0 2=1gen affact2_01=affact2recode affact2_01 1=0 2=1egen affact=rmean(affact1_01 affact2_01)label variable affact "affact1 afact2 0-1: 1=oppose aff action"
// Housing integrationrecode profil1 5 6=.recode profil2 5 6=.recode profil3 5 6=.recode deathpe 5 6=.recode favordp 3 4=.recode suspend 4 5=.recode nylaw 3 4=.recode innocen 3 4=. recode helpblc 3 4=.gen homeown01=homeownrecode homeown01 1=0 2=1label variable homeown0 "0-1 homeown, 1=up to homeowner"gen integr01=integrrecode integr01 1=0 2=.33 3=.67 4=1label variable integr01 "integr recoded to 0-1, 1=st. oppose"gen locgov01=locgovrecode locgov01 1=0 2=.33 3=.67 4=1label variable locgov01 "locgov: recoded to 0-1, 1=st oppose"egen housintegr=rmean (integr01 locgov01 homeown01)egen housintegr2=rmean(integr01 locgov01)label variable housintegr2 "housing integration -integr01 locgov01"//Aid to blacksgen helpblk01=helpblcrecode helpblk01 1=0 2=1gen spended01=spendedrecode spended01 1=0 2=.33 3=.67 4=1egen aidblk=rmean(helpblk01 spended01)//Racial Profilinggen profil2_01=profil2gen profil3_01=profil3recode profil2_01 1=0 2=.33 3=.67 4=1recode profil3_01 1=0 2=.33 3=.67 4=1egen rac_profil=rmean(profil2_01 profil3_01)label variable rac_profil "oppose action against officers: profiling" //Death Penalty Attitudesrecode deathpe 4=0 3=.33 2=.67 1=1 5=. 6=.recode favordp 2=0 1=1 3=. 4=.recode suspend 1=0 2=1 3=. 4=. 5=.recode nylaw 2=0 1=1 3=. 4=.recode innocen 2=0 1=1 3=. 4=.egen death_penalty=rmean(deathpe suspend nylaw innocen)label variable death_penalty "death penalty: deathpe suspend nylaw innoc"alpha integr01 locgov01 helpblk01 spended01 affact1_01 affact2_01, std gen(dv1)egen dv_1=rmean(integr01 locgov01 helpblk01 spended01 affact1_01 affact2_01)//Subjective Diversity
gen pcent=pct_aa
replace pcent=0 if nxtdoor==2
recode pcent (999 998 111=.)

//Media consumption
gen local=localtv
replace local=. if local==8

/* Skip creation of wave variables that require area and areacode */

//Primary Model includes %B-%W//Do not select below for figure. Scroll to **end**//******BEGIN*************First, Mean Center Everything*****
egen EGALITARIANISM=mean(egalitarianism) egen INDIVIDUALISM=mean(individualism) egen PID=mean(pid)egen LIBCON=mean(libcon) egen WORKBLA0=mean(workbla0) egen VIOLBLA0=mean(violbla0) egen SMONITOR=mean(smonitor) egen DIF=mean(dif)egen LNDIF=mean(lndif)egen HET=mean(het)
egen LOCAL=mean(local)
replace egalitarianism=egalitarianism-EGALITARIANISM replace individualism=individualism-INDIVIDUALISM replace pid=pid-PID replace libcon=libcon-LIBCON replace workbla0=workbla0-WORKBLA0 replace violbla0=violbla0-VIOLBLA0 replace smonitor=smonitor-SMONITOR replace dif=dif-DIFreplace lndif=lndif-LNDIF
replace het=het-HET
replace local=local-LOCAL//Correlation of stereotypes across levels of self monitoring
corr workbla0 violbla0 if smonitor> .1246931  & smonitor<.
corr workbla0 violbla0 if  smonitor<-.1253069 
corr workbla0 violbla0 if smonitor>-.1252  & smonitor<.125  
//summary measuresalpha integr01 locgov01 helpblk01 spended01 affact1_01 affact2_01
alpha deathpe suspend nylaw innocenalpha irish_r tryhard_r deserve_r slavery_rcorr blame_r poverty_rcorr eqright_r eqpeopl_r 
 /*** creating interactions with self monitoring and neighborhood composition**/
//model with difference black-white//
local h="dif"gen ZIPbXsm=`h'*smonitorgen workblaXsm=workbla0*smonitorgen violblaXsm=violbla0*smonitorgen workblaXZIPb=workbla0*`h'gen violblaXZIPb=violbla0*`h'gen workXsmXZIP=workbla0*`h'*smonitorgen vioXsmXZIP=violbla0*`h'*smonitor

/* Stop briefly to check ZIPbXsm */
sum ZIPbXsm

/* ** line added to use random number generator for imputation that was used for the version of Stata that Weber, et al. (2014) used ** */
set rng kiss32

//Impute Age. Linear projection of covariates. Things do not substantively change when interactions and dvs are included
mi query
mi set mlong
mi register imputed age 
mi register regular egalitarianism individualism  pid libcon  workbla0 violbla0 gender educ smonitor dif 
mi impute mvn age  =  egalitarianism individualism  pid libcon  workbla0 violbla0 gender educ smonitor dif , add(1) rseed(546) force 

//Mean center after imputation
egen AGE=mean(age)
replace age=age-AGE//Page 16 of Supplementary Materialsum dif, detailgen hiD=1 if dif>=.2360098   & dif<.
replace hiD=0 if dif<=-.1350976  

sum smonitor, detail
gen hiS=1 if smonitor>=.2913598      & smonitor<.
replace hiS=0 if smonitor<= -0.2919736

by hiD, sort: sum  egalitarianism individualism pid libcon  workbla0 violbla0 gender educ smonitor age dif

/* Comment out this section 

//Also for supplement
by zip, sort: gen count=_n
drop if count!=1
drop if hiD==.
sort hiD zip
keep hiD zip
 */

/* Skip down to models for Tables 3 and 4 */
/* Change ZIPbXsm with c.smonitor#c.dif */

//Dissembling Table Model (Reported in Tables 3 and 4)
mlogit mid1  egalitarianism individualism pid libcon gender educ smonitor age dif ZIPbXsm, base(3)mlogit mid2 egalitarianism individualism   pid libcon gender educ smonitor age  dif ZIPbXsm, base(2)

/* New code for the Paolino supplement begins here */
/* First mlogit command shows that interaction reproduces results from Weber, et al.'s (2014) code */

mlogit mid1  egalitarianism individualism pid libcon gender educ smonitor age dif c.smonitor#c.dif, base(3)

/* Predicted probabilities for lazy stereotype p.18 of the supplement */

margins, at((mean) _all gender=1 educ=0 (p10) dif (min) smonitor) at((mean) _all gender=1 educ=0 (p10) dif (max) smonitor) at((mean) _all gender=1 educ=0 (p90) dif (min) smonitor) at((mean) _all gender=1 educ=0 (p90) dif (max) smonitor) post

lincom _b[1bn._predict#4._at] - _b[1bn._predict#3._at]
lincom _b[1bn._predict#2._at] - _b[1bn._predict#1._at]

lincom (_b[1bn._predict#4._at] - _b[1bn._predict#3._at]) - (_b[1bn._predict#2._at] - _b[1bn._predict#1._at])

lincom _b[2._predict#4._at] - _b[2._predict#3._at]
lincom _b[2._predict#2._at] - _b[2._predict#1._at]

lincom (_b[2._predict#4._at] - _b[2._predict#3._at]) - (_b[2._predict#2._at] - _b[2._predict#1._at])

lincom _b[3._predict#4._at] - _b[3._predict#3._at]
lincom _b[3._predict#2._at] - _b[3._predict#1._at]

lincom _b[4._predict#4._at] - _b[4._predict#3._at]
lincom _b[4._predict#2._at] - _b[4._predict#1._at]

mlogit mid2 egalitarianism individualism   pid libcon gender educ smonitor age  dif c.smonitor#c.dif, base(2)

margins, at((mean) _all gender=1 educ=0 (p10) dif (min) smonitor) at((mean) _all gender=1 educ=0 (p10) dif (max) smonitor) at((mean) _all gender=1 educ=0 (p90) dif (min) smonitor) at((mean) _all gender=1 educ=0 (p90) dif (max) smonitor) post

/* Difference in predicted probabilities for midpoint for high and low self-monitors in diverse contexts -- p.18 of the supplement */

lincom _b[1bn._predict#4._at] - _b[1bn._predict#3._at]
lincom _b[1bn._predict#2._at] - _b[1bn._predict#1._at]

/* Difference in predicted probabilities for midpoint low self-monitors in low and highly diverse contexts -- p.19 of the supplement */

lincom _b[1bn._predict#1._at] - _b[1bn._predict#3._at]

lincom (_b[1bn._predict#4._at] - _b[1bn._predict#3._at]) - (_b[1bn._predict#2._at] - _b[1bn._predict#1._at])

lincom (_b[1bn._predict#4._at] - _b[2._predict#4._at]) - (_b[1bn._predict#3._at] - _b[2._predict#3._at])

lincom _b[2._predict#4._at] - _b[2._predict#3._at]
lincom _b[2._predict#2._at] - _b[2._predict#1._at]

lincom (_b[2._predict#4._at] - _b[2._predict#3._at]) - (_b[2._predict#2._at] - _b[2._predict#1._at])

lincom _b[3._predict#4._at] - _b[3._predict#3._at]
lincom _b[3._predict#2._at] - _b[3._predict#1._at]

/* Difference in predicted probabilities for opt-out low self-monitors in low and highly diverse contexts -- p.19 of the supplement */

lincom _b[4._predict#4._at] - _b[4._predict#3._at]
lincom _b[4._predict#2._at] - _b[4._predict#1._at]

lincom (_b[4._predict#4._at] - _b[4._predict#3._at]) - (_b[4._predict#2._at] - _b[4._predict#1._at])

mlogit mid2 egalitarianism individualism   pid libcon gender educ smonitor age  dif c.smonitor#c.dif, base(2)

margins, at((mean) _all dif=0 smonitor=(0 1)) at((mean) _all dif=1 smonitor=(0 1)) post

nlcom ln((_b[1bn._predict#4._at]/_b[2._predict#4._at])/(_b[1bn._predict#3._at]/_b[2._predict#3._at]))

egen smonitor_min=min(smonitor)

replace smonitor=smonitor-smonitor_min

label variable smonitor "Self-Monitoring"

mlogit mid2 egalitarianism individualism pid libcon gender educ smonitor age dif c.smonitor#c.dif, base(2)

/* Create Figure A.1 (b) */

margins, at((mean) _all gender=1 educ=0 (p90) dif smonitor=(0(.2)1)) predict(outcome(1)) post

marginsplot, xdimension(smonitor) title(Violent Stereotype--High Diversity) ytitle(Predicted Probability) plot1opts(lpattern(dash) msymbol(O)) recastci(rarea) yscale(range(0.15 0.6))

graph export figures/figureA1b.eps, as(eps) replace
/* Delete next two lines if not using linux */
!epstopdf /figures/figureA1b.eps -o=figures/figureA1b.pdf
!rm -f vshd.eps

mlogit mid2 egalitarianism individualism pid libcon gender educ smonitor age dif c.smonitor#c.dif, base(2)

/* Create Figure A.1 (a) */

margins, at((mean) _all gender=1 educ=0 (p10) dif smonitor=(0(.2)1)) predict(outcome(1)) post

marginsplot, xdimension(smonitor) title(Violent Stereotype--Low Diversity) ytitle(Predicted Probability) plot1opts(lpattern(dash) msymbol(O)) recastci(rarea) yscale(range(0.15 0.6))

graph export figures/figureA1a.eps, as(eps) replace
/* Delete next two lines if not using linux */
!epstopdf figures/figureA1a.eps -o=figures/figureA1avsld.pdf
!rm -f vsld.eps

mlogit mid2 egalitarianism individualism pid libcon gender educ smonitor age dif c.smonitor#c.dif, base(3)

mlogit mid2 egalitarianism individualism pid libcon gender educ smonitor age dif c.smonitor#c.dif, base(4)

log close
